package com.shawn.spring.boot.jpa.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

/**
 * @author shawn
 * @since 2020/8/31
 */
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@Data
public abstract class BaseEntity implements Serializable {

  @Column(name = "create_time", updatable = false)
  @CreationTimestamp
  private Date createTime;

  /** 上次更新时间 */
  @Column(name = "update_time")
  @UpdateTimestamp
  private Date updateTime;
}
